package main

// 多态行为

import "fmt"

type Shaper interface {
	Area() float64
}

type Square struct {
	side float64
}

func (s *Square) Area() float64 {
	return s.side * s.side
}

type Rectangle struct {
	x, y float64
}

func (r Rectangle) Area() float64 {
	return r.x * r.y
}

func main() {
	s := new(Square)
	s.side = 6.00
	r := Rectangle{3.00, 7.00}

	shapers := []Shaper{s, r}
	for _, v := range shapers {
		fmt.Println(v, " Area: ", v.Area())
	}
}
